import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
import { result } from 'lodash';
import { MessageService, UploadFileStatusEnum, UploadStatusEnum } from '@iux/live';

@Component({
  selector: 'app-limit',
  templateUrl: './limit.component.html',
  changeDetection:  ChangeDetectionStrategy.OnPush
})
export class LimitComponent {
  files;
  uploadStatus = UploadStatusEnum;
  constructor(private messageService: MessageService) {}

  change(e) {
    if (e.action === UploadFileStatusEnum.ERROR) {
      e.files[0]['errorTip'] = e.files[0].error.message || '自定义上传失败的原因';

      this.messageService.error(result(e, 'file.error.message') || '上传失败！');
    }
  }

}
